home *** CD-ROM | disk | FTP | other *** search
/ Freelog 22 / freelog 22.iso / Prog / Djgpp / GPC2952B.ZIP / info / gpc.i2 < prev    next >
Encoding:
GNU Info File  |  2001-02-09  |  50.3 KB  |  1,358 lines

  1. This is gpc.info, produced by makeinfo version 4.0 from gpc.texi.
  2.  
  3. INFO-DIR-SECTION GNU programming tools
  4. START-INFO-DIR-ENTRY
  5. * GPC: (gpc).                   The GNU Pascal Compiler.
  6. END-INFO-DIR-ENTRY
  7. INFO-DIR-SECTION Individual utilities
  8. START-INFO-DIR-ENTRY
  9. * GPC: (gpc)Invoking GPC.       The GNU Pascal Compiler.
  10. END-INFO-DIR-ENTRY
  11.  
  12.    This file documents the GNU Pascal Compiler.
  13.  
  14.    Copyright (C) 1988, 1996-2001 Free Software Foundation, Inc.
  15.  
  16.    Permission is granted to make and distribute verbatim copies of this
  17. manual provided the copyright notice and this permission notice are
  18. preserved on all copies.
  19.  
  20.    Permission is granted to copy and distribute modified versions of
  21. this manual under the conditions for verbatim copying, provided also
  22. that the sections entitled "GNU General Public License", "The GNU
  23. Project", "The GNU Manifesto" and "Funding for Free Software" are
  24. included exactly as in the original, and provided that the entire
  25. resulting derived work is distributed under the terms of a permission
  26. notice identical to this one.
  27.  
  28.    Permission is granted to copy and distribute translations of this
  29. manual into another language, under the above conditions for modified
  30. versions, except that the sections entitled "GNU General Public
  31. License", "The GNU Project", "The GNU Manifesto" and "Funding for Free
  32. Software" and this permission notice, may be included in translations
  33. approved by the Free Software Foundation instead of in the original
  34. English.
  35.  
  36. 
  37. File: gpc.info,  Node: Turbo Pascal compatibility,  Next: Supported platforms,  Prev: Current version,  Up: GNU Pascal
  38.  
  39. Is it compatible with Turbo Pascal (R)?
  40. ---------------------------------------
  41.  
  42.    GPC is not a drop-in replacement for Borland's Turbo Pascal (R).
  43. Almost all BP language features are supported. Notable exceptions are
  44. the string format (as discussed below), or the `Mem' and `Port' pseudo
  45. arrays, though replacement functions for the latter on x86 platforms
  46. exist in the `Ports' unit.
  47.  
  48.    Almost all of BP's run time library is supported in GPC, either by
  49. built-in compiler features or in units with the same names as their BP
  50. counterparts.
  51.  
  52.    For details about the compatibility, the few remaining
  53. incompatibilities and some useful alternatives to BP features, see the
  54. `Borland Pascal' chapter in the GPC Manual.  (*note Borland Pascal::)
  55.  
  56. 
  57. File: gpc.info,  Node: Supported platforms,  Prev: Turbo Pascal compatibility,  Up: GNU Pascal
  58.  
  59. Which platforms are supported by GNU Pascal?
  60. --------------------------------------------
  61.  
  62.    GPC uses the GCC backend, so it should run on any system that is
  63. supported by GNU CC. This includes a large variety of Unix systems,
  64. MS-DOS, OS/2 and Win32. A full list of platforms supported by GCC can
  65. be found in the file `INSTALL' of the GCC distribution. Not all of
  66. these have actually been tested, but it is known to run on these
  67. platforms:
  68.  
  69. ix86-linux                    (Linux 2.x, ELF)
  70. i486-linuxaout                
  71. i486-linuxoldld               
  72. i386-freebsd1.2.0             
  73. AIX 4.2.1                     
  74. AIX 4.3                       
  75. DJGPP V2                      (Dos)
  76. EMX 0.9B                      (OS/2, Dos)
  77. Cygwin32 beta20 and higher    (MS-Windows95/98, MS-Windows NT)
  78. Mingw32                       (MS-Windows95/98, MS-Windows NT)
  79. mips-sgi-irix5.3              
  80. sun-sparc-sunos4.1.4          
  81. sparc-sun-solaris2.x          
  82. sun-sparc-solaris 2.5.1       
  83. sun-sparc-solaris 2.6         
  84. sun-sparc-solaris 7           
  85. alpha-unknown-linux           
  86. alphaev56-dec-osf4.0d         
  87.  
  88.    *OK people - send us your success stories, with canonical machine
  89. name!*
  90.  
  91. 
  92. File: gpc.info,  Node: Installing GPC,  Next: GPC on DJGPP,  Prev: GNU Pascal,  Up: FAQ
  93.  
  94. Installing GPC
  95. ==============
  96.  
  97.    You find the most up-to-date installation instructions in the GPC
  98. Manual or the file `INSTALL' in source distributions, or on the GPC web
  99. site.  (*note Installation::)
  100.  
  101.    The following sections describe things you might need or want to
  102. install besides GPC itself.
  103.  
  104. * Menu:
  105.  
  106. * Documentation files::  What to read next
  107. * Components::           Which components do I need to compile Pascal code?
  108. * Debugger::             How do I debug my Pascal programs?
  109. * Libraries::            What additional libraries should I have?
  110. * Contributed units::    Contributed units
  111. * IDE::                  Can you recommend an IDE?
  112.  
  113. 
  114. File: gpc.info,  Node: Documentation files,  Next: Components,  Up: Installing GPC
  115.  
  116. What to read next
  117. -----------------
  118.  
  119.    After installing GPC, please check the files in the directory
  120. `/usr/local/doc/gpc':
  121.  
  122. `README'       General Information about GPC
  123. `FAQ'          This FAQ :-)
  124. `NEWS'         Changes since the last release
  125. `LIBS'         Libraries used by some GPC units
  126. `BUGS'         How to report bugs, about the Test Suite
  127. `AUTHORS'      List of GPC authors
  128. `COPYING'      The GNU General Public License
  129.  
  130. 
  131. File: gpc.info,  Node: Components,  Next: Debugger,  Prev: Documentation files,  Up: Installing GPC
  132.  
  133. Which components do I need to compile Pascal code?
  134. --------------------------------------------------
  135.  
  136.    A complete Pascal compiler system should at least have:
  137.  
  138.   1. The actual compiler, GPC.
  139.  
  140.   2. An editor, assembler, linker, librarian and friends.
  141.  
  142.   3. A C library. If you have a working C compiler, you already have
  143.      this.
  144.  
  145.   4. A debugger, if you want to debug your programs.
  146.  
  147.    For most people, the GNU binutils and GNU debugger (`gdb') are a
  148. good choice, although some may prefer to use vendor specific tools.
  149.  
  150. 
  151. File: gpc.info,  Node: Debugger,  Next: Libraries,  Prev: Components,  Up: Installing GPC
  152.  
  153. How do I debug my Pascal programs?
  154. ----------------------------------
  155.  
  156.    To debug your programs, (a) GNU Pascal must be able to generate
  157. executables with debug info for your platform, and (b) you must have a
  158. debugger which understands this.
  159.  
  160.    * If `gpc -g -o hello hello.p' says:
  161.           gpc: -g not supported for this platform
  162.      then GPC is unable to generate debugging info. Usually, installing
  163.      `gas' (part of GNU binutils) instead of your system's assembler
  164.      can overcome this. When you configure the GCC used for GPC, specify
  165.      `--with-gnu-as', and possibly `--with-gnu-ld' and/or
  166.      `--with-stabs'. More information can be found in the `INSTALL'
  167.      file in the GNU CC source directory.
  168.  
  169.    * Your system's debugger may not understand the debug info generated
  170.      by GNU tools. In this case, installing `gdb' may help.
  171.  
  172.    The bottom line: if you can debug GCC compiled programs, you should
  173. be able to do this with GPC too.
  174.  
  175.    The GNU debugger (`gdb') currently does not have a "Pascal" mode, so
  176. it is unable to display certain Pascal structures etc. When debugging,
  177. please note that the Initial Letter In Each Identifier Is In Upper Case
  178. And The Rest Are In Lower Case. If you want to display variable `foo'
  179. in the debugger, type `show Foo' or `display Foo' instead.
  180.  
  181.    Although `gdb' is an excellent debugger, it's user interface is not
  182. everybody's preference. If you like to debug under X11, please refer to
  183. the comp.windows.x FAQ: "Where can I get an X-based debugger?" at:
  184. `http://www.cis.ohio-state.edu/hypertext/faq/usenet/x-faq/part6/faq-doc-2.html'
  185.  
  186.    Some useful frontends include: XXGDB, tGDB and XWPE. See:
  187. `http://www.ee.ryerson.ca:8080/~elf/xapps/Q-IV.html'
  188.  
  189.    Very nice, but resource consuming is the Motif based DDD:
  190. `http://sol.ibr.cs.tu-bs.de/softech/ddd/'
  191.  
  192.    Furthermore, RHIDE (*note IDE::) contains built-in debugging suport,
  193. similar to the IDE of BP.
  194.  
  195. 
  196. File: gpc.info,  Node: Libraries,  Next: Contributed units,  Prev: Debugger,  Up: Installing GPC
  197.  
  198. What additional libraries should I have?
  199. ----------------------------------------
  200.  
  201.    You will need certain additional libraries when you compile some of
  202. the units. These can be found in the directory
  203. `ftp://agnes.dida.physik.uni-essen.de/gnu-pascal/libs/'.
  204.  
  205.    Currently, there are the following libraries:
  206.  
  207. gmp
  208.      Arithmetic for integers, rationals and real numbers with arbitrary
  209.      size and precision. Used by the GMP unit.
  210.  
  211. rx
  212.      Regular expression matching and substitution. Used by the RegEx
  213.      unit.
  214.  
  215. ncurses
  216. PDCurses
  217.      Screen handling. Used by the CRT unit. Depending on your system,
  218.      you have the following choices:
  219.  
  220.      Unix: You can compile terminal applications with ncurses and
  221.      applications that run in an X11 window with PDCurses (though
  222.      terminal applications can, of course, also run in an xterm under
  223.      X11). ncurses is used by default. If you want to use PDCurses
  224.      (a.k.a. XCurses), give the option `-DX11' when compiling CRT.
  225.  
  226.      Dos with DJGPP and MS-Windows with mingw: Only PDCurses is
  227.      available and will be used by default.
  228.  
  229.      MS-Windows with Cygwin: PDCurses and ncurses are available.
  230.      PDCurses is used by default. If you want to use ncurses, give the
  231.      option `-DUSE_NCURSES' when compiling CRT.
  232.  
  233.      Other systems: Please see the `README's and installation
  234.      instructions of PDCurses and ncurses to find out which one(s) can
  235.      be built on your system. See the conditionals at the end of
  236.      crt.inc and crtc.h (and change them if necessary) on which library
  237.      is used by default.
  238.  
  239. ElectricFence
  240.      This library is not used by any GPC unit. It is a debugging tool to
  241.      assist you in finding memory allocation bugs. To use it, just link
  242.      it to your program, either on the command line (`-lefence') or in
  243.      the source code (`{$L efence}') which you might want to put into
  244.      an `{$ifdef DEBUG}' or similar since using libefence is only
  245.      recommended for debugging.
  246.  
  247.    The source code of the libraries is available in the main `libs'
  248. directory. Most libraries come with one or several patches which should
  249. be applied before compiling them.
  250.  
  251.    Binaries for some platforms are available in the `binary/PLATFORM'
  252. subdirectories. If you compile the libraries for other platforms, be
  253. invited to make the binaries available to us for distribution on the
  254. FTP site.
  255.  
  256.    There are also the following files:
  257.  
  258. `terminfo-linux.tar.gz'
  259.      This is a patch to enable ncurses programs to make use of the
  260.      ability of Linux 2.2 and newer kernels to produce a block cursor
  261.      when needed. The present patch can be installed without recompiling
  262.      anything, just by copying some files into place. More details can
  263.      be found in the `README' file included in this archive. The patch
  264.      will not do any harm on older kernels. Please note that *not* only
  265.      on Linux machines it is useful to install the patch. Installing
  266.      them on any other machine will allow users who telnet in from a
  267.      Linux console to profit from the block cursor capability. Besides,
  268.      some Unix systems have installed older Linux terminfo entries or
  269.      none at all, so it's a good thing, anyway, to give them a current
  270.      version. The patch is included in the terminfo database of ncurses
  271.      5.0, so if you install ncurses 5.0 (source or binary), you don't
  272.      need to get the patch separately. But you can install it on a
  273.      system with an older ncurses version if you don't feel like
  274.      upgrading ncurses altogether.
  275.  
  276. `tsort-2.9i.zip'
  277.      A little utility (extracted from util-linux-2.9i, but not Linux
  278.      specific), needed for the configuration of the rx library. You
  279.      need it only if you compile rx yourself (and if it's not already
  280.      present on your system), not when using a rx binary.
  281.  
  282. 
  283. File: gpc.info,  Node: Contributed units,  Next: IDE,  Prev: Libraries,  Up: Installing GPC
  284.  
  285. Contributed units
  286. -----------------
  287.  
  288.    Several people have contributed units for GPC. They are usually
  289. announced on the mailing list, *Note Mailing List::. Here's a selection:
  290.  
  291.    * Nicola Girardi wrote a unit which you can use to interface Svgalib.
  292.      You can read a mini-FAQ about it at
  293.      `http://ages.dida.physik.uni-essen.de/~nicola/', complete with
  294.      links to download the unit via http or ftp. If you want to download
  295.      the unit directly, get `svgalib-gpc-20000216.tar.gz' from
  296.      `ftp://agnes.dida.physik.uni-essen.de/home/nicola/'.
  297.  
  298.    * Prof. Abimbola A. Olowofoyeku ("The African Chief") wrote a
  299.      Delphi-compatible (though a few routines are still missing)
  300.      `SysUtils' unit. It has been tested under Cygwin, Mingw, Linux
  301.      (Mandrake 7.0), and Solaris 7. It can be downloaded from
  302.      `ftp://agnes.dida.physik.uni-essen.de/home/chief/sysutils-20000725.zip'.
  303.  
  304.    * Eike Lange wrote units to access MySql, GNU DBM and PostgreSQL data
  305.      bases. As of this writing (Aug 2000), they are in Alpha stage. They
  306.      can be downloaded from
  307.      `ftp://agnes.dida.physik.uni-essen.de/home/lange/'.
  308.  
  309. 
  310. File: gpc.info,  Node: IDE,  Prev: Contributed units,  Up: Installing GPC
  311.  
  312. Can you recommend an IDE?
  313. -------------------------
  314.  
  315.    Users of Borland Pascal may wonder if there's a replacement for the
  316. IDE (Integrated Development Environment). Here's a few suggestions:
  317.  
  318.    * (X)Emacs. Some people think it's the answer to the question of
  319.      Life, the Universe and Everything, others decide it's uGNUsable.
  320.      Available from your friendly GNU mirror and most distributions.
  321.  
  322.    * RHIDE. DJGPP users might want to try RHIDE. The latest (beta)
  323.      release is compatible with GNU Pascal and allows stepping, tracing
  324.      and watching like Borland's IDE. It can be downloaded from
  325.      `http://www.tu-chemnitz.de/~sho/rho/rhide/rhide.html'.
  326.  
  327.    * PENG. It's not free software, but it was written with GPC.  It's
  328.      very similar to Borland's IDE, but with many extensions.  Binaries
  329.      for DJGPP, Linux and Solaris can be downloaded from
  330.      `http://fjf.gnu.de/peng.html'.
  331.  
  332.    * XWPE is another imitation of the Borland IDE, so users of Borland
  333.      Pascal may find it a good alternative.
  334.  
  335. 
  336. File: gpc.info,  Node: GPC on DJGPP,  Next: Strings in GPC,  Prev: Installing GPC,  Up: FAQ
  337.  
  338. GNU Pascal on the DJGPP (MS-DOS) platform
  339. =========================================
  340.  
  341.    This chapter discusses some potential problems with GNU Pascal on
  342. MS-DOS, using DJGPP.
  343.  
  344. * Menu:
  345.  
  346. * What is DJGPP::            What is DJGPP?
  347. * DJGPP FAQ::                If you need more information
  348. * DJGPP download::           What do I download?
  349. * Installing GPC on DJGPP::  How do I install the compiler?
  350. * DJGPP Info reader::        I cannot read the Info documentation!
  351. * DJGPP DPMI server::        GPC says: no DPMI
  352. * Assembler syntax::         I have troubles with assembly code
  353. * DJGPP specific code::      Tell me how to do DPMI, BIOS and
  354.                              other DOS related things.
  355. * DJGPP stack size::         I got an exception when accessing an
  356.                              `array [1 .. 4000000] of Byte'.
  357.  
  358. 
  359. File: gpc.info,  Node: What is DJGPP,  Next: DJGPP FAQ,  Up: GPC on DJGPP
  360.  
  361. What is DJGPP?
  362. --------------
  363.  
  364.    The following paragraph is from the site
  365. `http://www.delorie.com/djgpp/':
  366.  
  367.    DJGPP is a complete 32-bit C/C++ development system for Intel 80386
  368. (and higher) PCs running DOS. It includes ports of many GNU development
  369. utilities. The development tools require a 80386 or newer computer to
  370. run, as do the programs they produce. In most cases, the programs it
  371. produces can be sold commercially without license or royalties.
  372.  
  373. 
  374. File: gpc.info,  Node: DJGPP FAQ,  Next: DJGPP download,  Prev: What is DJGPP,  Up: GPC on DJGPP
  375.  
  376. If you need more information
  377. ----------------------------
  378.  
  379.    GPC/DJGPP is a DJGPP V2 application, and most of the DJGPP
  380. documentation applies for GPC too. A great source of information is the
  381. DJGPP FAQ: `http://www.delorie.com/djgpp/v2faq/230b.zip'
  382.  
  383.    Another place to look for DJGPP documentation is the DJGPP Knowledge
  384. Base, at this URL: `http://www.delorie.com/djgpp/doc/kb/'
  385.  
  386. 
  387. File: gpc.info,  Node: DJGPP download,  Next: Installing GPC on DJGPP,  Prev: DJGPP FAQ,  Up: GPC on DJGPP
  388.  
  389. What do I download?
  390. -------------------
  391.  
  392.    As discussed in *Note Components::, other than GPC itself, you need
  393. an assembler, linker and friends, a C library and possibly a debugger.
  394. The site `http://www.delorie.com/djgpp/' recommended the following
  395. files and they will help you find a mirror:
  396.  
  397. `v2/djdev203.zip'       (C library)
  398. `v2gnu/bnu2951b.zip'    (assembler, ....)
  399. `v2gnu/gcc2952b.zip'    (gcc)
  400. `v2gnu/gdb418b.zip'     (debugger)
  401. `v2gnu/mak379b.zip'     (make)
  402. `v2gnu/txi40b.zip'      (texi)
  403.  
  404.    This list is about 10 MB not counting GPC. You can use a binary
  405. version of GPC from agnes.
  406.  
  407. 
  408. File: gpc.info,  Node: Installing GPC on DJGPP,  Next: DJGPP Info reader,  Prev: DJGPP download,  Up: GPC on DJGPP
  409.  
  410. How do I install the compiler?
  411. ------------------------------
  412.  
  413.    If you don't have DJGPP installed on your harddisk, create a
  414. directory for GNU Pascal (`c:\gpc'), and unzip the archives.  Make sure
  415. you preserve the directory structure (use `pkunzip -d'). Now, add the
  416. directory where `gpc.exe' lives (`c:\gpc\bin') to your path and set the
  417. DJGPP environment variable to point to your `djgpp.env' file:
  418.  
  419.      set DJGPP=c:\gpc\djgpp.env
  420.  
  421.    Then, add this to your `djgpp.env' file:
  422.  
  423.      ---------------------------------------------------------
  424.      [gpcpp]
  425.      C_INCLUDE_PATH=%/>;C_INCLUDE_PATH%%DJDIR%/lang/pascal;%DJDIR%/include
  426.      
  427.      [gpc]
  428.      COMPILER_PATH=%/>;COMPILER_PATH%%DJDIR%/bin
  429.      LIBRARY_PATH=%/>;LIBRARY_PATH%%DJDIR%/lib;%DJDIR%/contrib/grx20/lib
  430.      ---------------------------------------------------------
  431.  
  432.    The binary distribution should come with a `djgpp.env' which is
  433. already modified, so you may not have to do this.
  434.  
  435.    The GPC online documentation is in GNU info format; you need the
  436. Info reader (`txi390b.zip') to read it, or use the built-in Info reader
  437. of the RHIDE or PENG IDE. To add the GPC documentation to the info
  438. directory file, edit the `c:\gpc\info\dir' file, and locate this
  439. section:
  440.  
  441.      ---------------------------------------------------------
  442.      * GCC: (gcc.inf).
  443.      The GNU C, C++, and Objective-C Compiler
  444.      
  445.      * GDB: (gdb.inf).
  446.      The GNU Debugger (gdb and gdb-dpmi).
  447.      
  448.      ---------------------------------------------------------
  449.  
  450.    To add GPC, change it to look like this:
  451.  
  452.      ---------------------------------------------------------
  453.      * GCC: (gcc.inf).
  454.      The GNU C, C++, and Objective-C Compiler
  455.      
  456.      * GPC: (gpc.inf).
  457.      The GNU Pascal Compiler
  458.      
  459.      * GDB: (gdb.inf).
  460.      The GNU Debugger (gdb and gdb-dpmi).
  461.      
  462.      ---------------------------------------------------------
  463.  
  464.    Specific information for low-memory conditions and more can be found
  465. in the DJGPP FAQ and documentation.
  466.  
  467. 
  468. File: gpc.info,  Node: DJGPP Info reader,  Next: DJGPP DPMI server,  Prev: Installing GPC on DJGPP,  Up: GPC on DJGPP
  469.  
  470. I cannot read the Info documentation!
  471. -------------------------------------
  472.  
  473.    To read the Info documentation, you need the `info' program from
  474. `txi390b.zip' or an IDE like RHIDE or PENG.
  475.  
  476. 
  477. File: gpc.info,  Node: DJGPP DPMI server,  Next: Assembler syntax,  Prev: DJGPP Info reader,  Up: GPC on DJGPP
  478.  
  479. GPC says: no DPMI
  480. -----------------
  481.  
  482.    You don't have a DPMI server installed, and DJGPP v2 requires it to
  483. run. You can either use one of the commercial DPMI servers (e.g., run
  484. `gpc' in a DOS box under MS-Windows) or download and install CWSDPMI
  485. (`csdpmi3b.zip') which is a free DPMI server written for DJGPP.
  486.  
  487. 
  488. File: gpc.info,  Node: Assembler syntax,  Next: DJGPP specific code,  Prev: DJGPP DPMI server,  Up: GPC on DJGPP
  489.  
  490. I have troubles with assembly code
  491. ----------------------------------
  492.  
  493.    The GNU Assembler (`as.exe'), or `gas', called by GCC accepts "AT&T"
  494. syntax which is different from "Intel" syntax.  Differences are
  495. discussed in section 17.1 of the DJGPP FAQ.
  496.  
  497.    A guide is available which was written by Brennan Mr. Wacko
  498. Underwood <brennan@mack.rt66.com> and describes how to use inline
  499. assembly programming with DJGPP, at this URL:
  500. `http://www.rt66.com/~brennan/djgpp/djgpp_asm.html'
  501.  
  502.    There's also a GPC assembler tutorial at
  503. `ftp://agnes.dida.physik.uni-essen.de/gnu-pascal/contrib/gpcasm.zip'
  504.  
  505.    Section 17.3 of the DJGPP FAQ discusses some methods to convert
  506. "Intel" syntax to "AT&T" syntax.
  507.  
  508. 
  509. File: gpc.info,  Node: DJGPP specific code,  Next: DJGPP stack size,  Prev: Assembler syntax,  Up: GPC on DJGPP
  510.  
  511. Tell me how to do DPMI, BIOS and other DOS related things.
  512. ----------------------------------------------------------
  513.  
  514.    DPMI, BIOS and other functions are no different than other system
  515. functions. Refer to the GPC Manual on how to access your system's
  516. C-library. This small example shows how to use DPMI, copying some
  517. structures and function prototypes of `<dpmi.h>':
  518.  
  519.      program DPMIDemo;
  520.      
  521.      { Only for DJGPP }
  522.      
  523.      {$X+}
  524.      
  525.      { `Byte' is `unsigned char' in C,
  526.        `ShortCard' is `unsigned short' in C,
  527.        `MedCard' is `unsigned long' in C,
  528.        `Word' is `unsigned' in C,
  529.        etc. (all these types are built-in). }
  530.      
  531.      type
  532.        TDpmiVersionRet = record
  533.          Major      : Byte;
  534.          Minor      : Byte;
  535.          Flags      : ShortCard;
  536.          CPU        : Byte;
  537.          Master_PIC : Byte;
  538.          Slave_PIC  : Byte;
  539.        end;
  540.      
  541.      type
  542.        TDpmiFreeMemInfo = record
  543.          Largest_Available_Free_Block_In_Bytes,
  544.          Maximum_Unlocked_Page_Allocation_In_Pages,
  545.          Maximum_Locked_Page_Allocation_In_Pages,
  546.          Linear_Address_Space_Size_In_Pages,
  547.          Total_Number_Of_Unlocked_Pages,
  548.          Total_Number_Of_Free_Pages,
  549.          Total_Number_Of_Physical_Pages,
  550.          Free_Linear_Address_Space_In_Pages,
  551.          Size_Of_Paging_File_Partition_In_Pages,
  552.          Reserved1,
  553.          Reserved2,
  554.          Reserved3 : MedCard;
  555.        end;
  556.      
  557.      function DpmiGetVersion (var Version: TDpmiVersionRet): Integer;
  558.               asmname '__dpmi_get_version';
  559.      
  560.      function DpmiGetFreeMemoryInformation
  561.               (var MemInfo: TDpmiFreeMemInfo): Integer;
  562.               asmname '__dpmi_get_free_memory_information';
  563.      
  564.      var
  565.        Version: TDpmiVersionRet;
  566.        MemInfo: TDpmiFreeMemInfo;
  567.      
  568.      begin
  569.        if DpmiGetVersion (Version) = 0 then
  570.          begin
  571.            WriteLn ('CPU type :       ', Version.cpu, '86');
  572.            WriteLn ('DPMI major :       ', Version.Major);
  573.            WriteLn ('DPMI minor :       ', Version.Minor);
  574.          end
  575.        else
  576.          WriteLn ('Error in DpmiGetVersion');
  577.        if DpmiGetFreeMemoryInformation (MemInfo) = 0 then
  578.          WriteLn ('Free DPMI memory : ',
  579.                   MemInfo.Total_Number_Of_Free_Pages, ' pages.')
  580.        else
  581.          WriteLn ('Error in DpmiGetMemoryInformation');
  582.      end.
  583.  
  584. 
  585. File: gpc.info,  Node: DJGPP stack size,  Prev: DJGPP specific code,  Up: GPC on DJGPP
  586.  
  587. I got an exception when accessing an `array [1 .. 4000000] of Byte'.
  588. --------------------------------------------------------------------
  589.  
  590.    Per default, the maximum stack size of a DJGPP application is 256K.
  591. If you need more, you have to adjust it with the stubedit program, i.e.:
  592.  
  593.      stubedit your_app.exe minstack=5000K
  594.  
  595.    Another way is to add the following code to your program to define a
  596. minimum stack size (here: 2 MB). This value will be honored even if a
  597. user sets a lower value by using stubedit, so this method might be a
  598. little safer.
  599.  
  600.    Note: The syntax given here is valid for GPC releases of May 2000
  601. and newer.
  602.  
  603.      {$ifdef DJGPP}
  604.      const
  605.        MinStackSize : Cardinal = $200000; asmname '_stklen';
  606.      {$endif}
  607.  
  608.    Still, it might be a good idea to use pointers for large structures,
  609. and allocate the memory at runtime.
  610.  
  611. 
  612. File: gpc.info,  Node: Strings in GPC,  Next: Getting Help,  Prev: GPC on DJGPP,  Up: FAQ
  613.  
  614. Strings
  615. =======
  616.  
  617. * Menu:
  618.  
  619. * String schema::               What's this confusion about strings?
  620. * Strings in variant records::  Overlaying strings in variant records
  621. * Length byte::                 Why does `s[0]' not contain the length?
  622. * Short strings::               Support for BP compatible short strings
  623. * C strings::                   What about C strings?
  624.  
  625. 
  626. File: gpc.info,  Node: String schema,  Next: Strings in variant records,  Up: Strings in GPC
  627.  
  628. What's this confusion about strings?
  629. ------------------------------------
  630.  
  631.    Turbo Pascal strings have a length byte in front. Since a byte has
  632. the range 0 .. 255, this limits a string to 255 characters. However,
  633. the Pascal string schema, as defined in section 6.4.3.3.3 of the
  634. ISO-10206: 1990 Extended Pascal standard, is a schema record:
  635.  
  636.      type
  637.        String (Capacity : Integer) = record
  638.          Length : 0 .. Capacity;
  639.          String : packed array [1 .. Capacity + 1] of Char
  640.        end;
  641.  
  642.    The `+ 1' is a GPC extension to make it feasible to automatically
  643. add the `#0' terminator when passing or assigning them to CStrings.
  644. Thus at the expense of a little added complexity (must declare
  645. capacity, don't use `GetMem' without explicit initialization of the
  646. `Capacity' field, and the additional space requirement) you can now
  647. have very long strings.
  648.  
  649. 
  650. File: gpc.info,  Node: Strings in variant records,  Next: Length byte,  Prev: String schema,  Up: Strings in GPC
  651.  
  652. Overlaying strings in variant records
  653. -------------------------------------
  654.  
  655.    Q: Should the different variants in a variant record overlay in the
  656. same memory? Previous Pascals I have used have guaranteed this, and
  657. I've got low-level code that relies on this. The variants are not the
  658. same length, and they are intended not to be.
  659.  
  660.    A: No, this is intentional so that the discriminants are not
  661. overwritten, and they can be properly initialized in the first place.
  662. Consider:
  663.  
  664.      record
  665.      case Boolean of
  666.        False: (s1 : String (42));
  667.        True:  (s2 : String (99));
  668.      end;
  669.  
  670.    If the strings would overlay, in particular their discriminants
  671. would occupy the same place in memory. How should it be initialized?
  672. Either way, it would be wrong for at least one of the variants...
  673.  
  674.    So, after a discussion in comp.lang.pascal.ansi-iso where this topic
  675. came up concerning file variables (which also require some automatic
  676. initialization and finalization), we decided to do this in GPC for all
  677. types with automatic initialization and finalization (currently files
  678. and schemata, in the future this might also be Delphi compatible
  679. classes and user-defined initialized and finalized types), since the
  680. standard does not guarantee variants to overlay, anyway...
  681.  
  682.    There are two ways in GPC to get guaranteed overlaying (both
  683. non-standard, of course, since the standard does not assume anything
  684. about internal representations; both BP compatible), `absolute'
  685. declarations and variable type casts. E.g., in order to overlay a byte
  686. array `b' to a variable `v':
  687.  
  688.      var
  689.        b: array [1 .. SizeOf (v)] of Byte absolute v;
  690.  
  691.    Or you can use type-casting:
  692.  
  693.      type
  694.        t = array [1 .. SizeOf (v)] of Byte;
  695.  
  696.    then `t (v)' can be used as a byte array overlayed to `v'.
  697.  
  698. 
  699. File: gpc.info,  Node: Length byte,  Next: Short strings,  Prev: Strings in variant records,  Up: Strings in GPC
  700.  
  701. Why does `s[0]' not contain the length?
  702. ---------------------------------------
  703.  
  704.    Q: In standard Pascal you expect `s[1]' to align with the first
  705. character position of `s' and thus one character to the left is the
  706. length of `s'. Thus `s[0]' is the length of `s'.  True?
  707.  
  708.    A: This holds for UCSD/BP strings (which GPC does not yet implement,
  709. but that's planned). The only strings Standard Pascal knows are arrays
  710. of char without any length value.
  711.  
  712.    GPC also supports Extended Pascal string schemata (*note String
  713. schema::), but they also don't have a length byte at "position 0", but
  714. rather a `Length' field (which is larger than one byte).
  715.  
  716. 
  717. File: gpc.info,  Node: Short strings,  Next: C strings,  Prev: Length byte,  Up: Strings in GPC
  718.  
  719. Support for BP compatible short strings
  720. ---------------------------------------
  721.  
  722.    Q: Two different kinds of strings with the same name - `String' -
  723. does make a bit of confusion. Perhaps the oldstyle strings could be
  724. renamed `short string' ?
  725.  
  726.    A: When we implement the short strings, we'll have to do such a
  727. distinction. Our current planning goes like this:
  728.  
  729.    `String (N)': string schema (EP compatible)
  730.  
  731.    `String [N]': short string (UCSD/BP compatible, where N must be <=
  732. 255)
  733.  
  734.    `String': dependent on flags, by default undiscriminated schema, but
  735. in BP mode (or with a special switch) short string of capacity 255
  736. (UCSD/BP compatible).
  737.  
  738.    Q: So when will these short strings be available?
  739.  
  740.    A: It's been planned for over a year. The delay has been caused by
  741. more pressing problems.
  742.  
  743. 
  744. File: gpc.info,  Node: C strings,  Prev: Short strings,  Up: Strings in GPC
  745.  
  746. What about C strings?
  747. ---------------------
  748.  
  749.    A C string (`char *') is an array of char, terminated with a `#0'
  750. char.
  751.  
  752.    C library functions require C, not Pascal style string arguments.
  753. However, Pascal style strings are automatically converted to C style
  754. strings when passed to a routine that expects C style strings. This
  755. works only if the routine reads from the string, not if it modifies it.
  756.  
  757.    E.g., this is how you could access the `system()' call in your C
  758. library (which is not necessary anymore, since `Execute' is already
  759. built-in):
  760.  
  761.      program SysCall;
  762.      
  763.      function System (Name : CString): Integer; asmname 'system';
  764.      
  765.      var
  766.        Result : Integer;
  767.      
  768.      begin
  769.        Result := System ('ls -l');
  770.        WriteLn ('system() call returned : ', Result)
  771.      end.
  772.  
  773.    You could use the type `PChar' instead of `CString'. Both `CString'
  774. and `PChar' are predefined as `^Char' - though we recommend `CString'
  775. because it makes it clearer that we're talking about some kind of
  776. string rather than a single character.
  777.  
  778.    A lot of library routines in Pascal for many applications exist in
  779. the GPC unit and some other units. Where available, they should be
  780. preferred (e.g. `Execute' rather than `system()', and then you won't
  781. have to worry about `CString's.)
  782.  
  783.    Do *not* pass a C style string as a `const' or `var' argument if the
  784. C prototype says `const char *' or you will probably get a segfault.
  785.  
  786. 
  787. File: gpc.info,  Node: Getting Help,  Next: Miscellaneous FAQ,  Prev: Strings in GPC,  Up: FAQ
  788.  
  789. Getting Help
  790. ============
  791.  
  792.    Please read the GPC Manual (info files or other formats) as well as
  793. the `README' and `BUGS' files that come with GPC (usually installed in
  794. directory `/usr/local/doc/gpc'), plus other docs that might help (the
  795. DJGPP FAQ if you use DJGPP, etc.) before you send email to the
  796. maintainers or mailing list.
  797.  
  798.    In particular, the `BUGS' file contains information on how to submit
  799. bug reports in the most efficient way.
  800.  
  801.    The `Support' chapter of the GPC Manual tells you where to find more
  802. information about GPC and how to contact the GPC developers.  (*note
  803. Support::)
  804.  
  805. 
  806. File: gpc.info,  Node: Miscellaneous FAQ,  Prev: Getting Help,  Up: FAQ
  807.  
  808. Miscellaneous
  809. =============
  810.  
  811. * Menu:
  812.  
  813. * Contributing::           I want to contribute; where do I start?
  814. * GPC FTP and WWW sites::  Where is the GNU Pascal FTP site? WWW?
  815. * About the FAQ::          About this FAQ
  816.  
  817. 
  818. File: gpc.info,  Node: Contributing,  Next: GPC FTP and WWW sites,  Up: Miscellaneous FAQ
  819.  
  820. I want to contribute; where do I start?
  821. ---------------------------------------
  822.  
  823.    If you want to contribute, please write to the mailing list, *Note
  824. Mailing List::.
  825.  
  826. 
  827. File: gpc.info,  Node: GPC FTP and WWW sites,  Next: About the FAQ,  Prev: Contributing,  Up: Miscellaneous FAQ
  828.  
  829. Where is the GNU Pascal FTP site? WWW?
  830. --------------------------------------
  831.  
  832.    The GPC homepage on the web is
  833. `http://home.pages.de/~GNU-Pascal/'.
  834.  
  835.    For now, this same page appears at
  836. `http://agnes.dida.physik.uni-essen.de/~gnu-pascal/'.
  837.  
  838.    The master FTP site for GNU Pascal is
  839. `agnes.dida.physik.uni-essen.de'.
  840.  
  841.    GNU Pascal related files can be found in
  842. `ftp://agnes.dida.physik.uni-essen.de/gnu-pascal/'.
  843.  
  844.    GPC To-Do list, latest features, fixed bugs:
  845. `http://agnes.dida.physik.uni-essen.de/~gnu-pascal/todo.html'
  846.  
  847. 
  848. File: gpc.info,  Node: About the FAQ,  Prev: GPC FTP and WWW sites,  Up: Miscellaneous FAQ
  849.  
  850. About this FAQ
  851. --------------
  852.  
  853.    Current Maintainer: Russ Whitaker <russ@ashlandhome.net>
  854.  
  855.    This is the second incarnation of the GNU Pascal FAQ list. Comments
  856. about, suggestions for, or corrections to this FAQ list are welcome.
  857.  
  858.    This FAQ is based on GNU Pascal Frequently-Asked Questions List,
  859. Edition 0.4, for GPC version 2.0, November 1996 by J.J. van der Heijden
  860. <j.j.vanderheijden@student.utwente.nl>.
  861.  
  862.    Please make sure to include in your mail the version number of the
  863. document to which your comments apply (you can find the version at the
  864. beginning of this FAQ list).
  865.  
  866.    Many people have contributed to this FAQ, only some of them are
  867. acknowledged above. Much of the info in, and inspiration for this FAQ
  868. list was taken from the GPC mailing list traffic, so you may have
  869. (unbeknownst to you) contributed to this list.
  870.  
  871. 
  872. File: gpc.info,  Node: Installation,  Next: Borland Pascal,  Prev: FAQ,  Up: Top
  873.  
  874. How to download, compile and install GNU Pascal.
  875. ************************************************
  876.  
  877. * Menu:
  878.  
  879. * Download::              Where and what to download
  880. * Binary Distributions::  How to install a binary distribution
  881. * Compiling GPC::         How to compile GPC
  882. * Compilation Notes::     Compilation notes for specific platforms
  883. * Cross-Compilers::       Building and Installing a cross-compiler
  884. * Crossbuilding::         Crossbuilding a compiler
  885.  
  886. 
  887. File: gpc.info,  Node: Download,  Next: Binary Distributions,  Up: Installation
  888.  
  889. Where and what to download
  890. ==========================
  891.  
  892.    The master server for GNU Pascal is
  893. `agnes.dida.physik.uni-essen.de'. Official and beta releases of the
  894. compiler with sources and binaries for many platforms as well as other
  895. GNU Pascal related files can be found in
  896.  
  897.      `ftp://agnes.dida.physik.uni-essen.de/gnu-pascal/'
  898.  
  899.    You can find binary distributions for many platforms in the
  900. subdirectory `binary'. The archive files are named
  901. `gpc-VERSION.PLATFORM.EXTENSION' - for example
  902. `gpc-2.1.alpha-unknown-linux-gnu.tar.gz' for GPC version 2.1 on an
  903. Alpha workstation running the Linux kernel with GNU C Library, or
  904. `gpc-20000616.i586-pc-djgppv201.zip' for GPC version 20000616 on an
  905. i586 PC running DOS with DJGPP version 2.01.
  906.  
  907.    After you have downloaded the correct archive file for your
  908. platform, please read the installation notes on how to install such a
  909. binary distribution.
  910.  
  911.    If you are running Dos or MS Windows, you will need additional tools
  912. - see "What else to download and where" below.
  913.  
  914. Current snapshots
  915. -----------------
  916.  
  917.    GNU Pascal is subject to steady development. You can download the
  918. current snapshot (source only, use at your own risk) via anonymous FTP
  919. from:
  920.  
  921.      `ftp://agnes.dida.physik.uni-essen.de/gnu-pascal/alpha/'
  922.  
  923. or via anonymous CVS from:
  924.  
  925.      CVS root:
  926.        :pserver:anonymous@agnes.dida.physik.uni-essen.de:/usr/local/cvsroot
  927.      Password:
  928.        anonymous
  929.      Command:
  930.        checkout gpc
  931.  
  932.    Please read the installation notes on how to compile the source from
  933. a distribution or a CVS checkout.
  934.  
  935. What else to download and where
  936. -------------------------------
  937.  
  938.    When you are using GNU Pascal on a DOS system, you will need either
  939. the DJGPP or the EMX development environment (see below). On an OS/2
  940. system, you will need EMX. On an MS Windows 95/98/NT system you will
  941. need either the CygWin or the mingw32 environment.
  942.  
  943.    GNU Pascal uses the compiler back-end from the GNU Compiler
  944. Collection, GNU CC or GCC. If you want to compile GPC, you will need
  945. the source of GCC, version version 2.95.x, as well as the source of GPC
  946. itself. Please download it from the same place as GPC, or from any GNU
  947. FTP mirror. (See the list on the GNU home page,
  948. `http://www.gnu.org/gnu/order/ftp.html', for the site closest to you.)
  949.  
  950. Libraries
  951. ---------
  952.  
  953.    For some of GPC's units, you will need some standard libraries. In
  954. particular:
  955.  
  956. Unit             Platform              Library
  957. CRT              Unix/terminal         ncurses >= 5.0 (1), (2)
  958. CRT              Unix/X11              PDCurses (2)
  959. CRT              Dos, MS-Windows       PDCurses (3)
  960. GMP              any                   gmp
  961. RegEx            any                   rx
  962. (debugging)      Unix, MS-Windows      ElectricFence (4)
  963.  
  964.    Notes:
  965.  
  966.    (1) ncurses version 5.0 or newer is strongly recommended because
  967. older versions contain a bug that severely affects CRT programs.
  968.  
  969.    (2) You can install both ncurses and PDCurses on a Unix system, and
  970. choose at compile time whether to generate a terminal or X11 version of
  971. your program.
  972.  
  973.    (3) ncurses also runs under MS-Windows with CygWin (not mingw32,
  974. however), but doesn't appear to behave much differently from PDCurses
  975. on that platform.
  976.  
  977.    (4) ElectricFence is not used by any unit, but can be used for
  978. debugging memory allocation bugs by simply linking it (see the
  979. accompanying documentation).
  980.  
  981.    You can find those libraries on many places on the Net. Also, many
  982. GNU/Linux distributions, DJGPP mirrors and other OS distributions
  983. already contain some of the libraries. In any case, you can find the
  984. sources of the libraries (sometimes together with patches that you
  985. should apply before building if you choose to build from the sources)
  986. and binaries for some platforms in
  987.  
  988.      `ftp://agnes.dida.physik.uni-essen.de/gnu-pascal/libs/'
  989.  
  990. DJGPP
  991. -----
  992.  
  993.    DJGPP (http://www.delorie.com/djgpp/) is available from any SimTel
  994. mirror in the `gnu/djgpp' subdirectory; for FTP addresses look into the
  995. DJGPP FAQ (http://www.delorie.com/djgpp/v2faq/). For using GNU Pascal
  996. you need at least
  997.  
  998.    - the C library, `v2/djdev201.zip', and
  999.  
  1000.    - `binutils' (assembler, etc.), `v2gnu/bnu270b.zip'.
  1001.  
  1002.    We also recommend you to get:
  1003.  
  1004.    - the `make' utility, `v2gnu/mak375b.zip'
  1005.  
  1006.    - the GNU debugger, `v2gnu/gdb416b.zip'
  1007.  
  1008.    - the DJGPP FAQ, `v2faq/faq211b.zip'
  1009.  
  1010.    - the GRX graphics library, `http://www.gnu.de/software/GRX/'
  1011.  
  1012.    - PENG, `http://fjf.gnu.de/peng.html', an integrated development
  1013.      environment, similar to BP's one, written in GNU Pascal, or
  1014.  
  1015.    - RHIDE, `v2app/rhide.zip', another integrated development
  1016.      environment.
  1017.  
  1018. EMX
  1019. ---
  1020.  
  1021.    EMX is an environment for creating 32-bit applications for DOS and
  1022. OS/2.  It is available from:
  1023.  
  1024.      `http://www.leo.org/pub/comp/os/os2/leo/gnu/emx+gcc/index.html'
  1025.  
  1026.    To develop EMX programs with GNU Pascal you need at least
  1027.  
  1028.    - the EMX runtime package, `emxrt.zip',
  1029.  
  1030.    - the EMX development system, `emxdev*.zip', and
  1031.  
  1032.    - the GNU development tools, `gnudev*.zip'.
  1033.  
  1034.    If your DOS box has DPMI (it does if you are using MS Windows or
  1035. OS/2) you will also need RSX, available from the same sites as EMX in
  1036. the subdirectory `rsxnt'.
  1037.  
  1038.    The GNU development tools contain the GNU C compiler which is in fact
  1039. not needed to use GNU Pascal. However, the C library _is_ needed.
  1040.  
  1041. CygWin
  1042. ------
  1043.  
  1044.    CygWin is an environment which implements a POSIX layer under MS
  1045. Windows, giving it large parts of the functionality of Unix. CygWin
  1046. contains development tools such as an assembler, a linker, etc. GPC
  1047. needs for operation. More information about CygWin can be found at:
  1048.  
  1049.      `http://www.cygnus.com/cygwin/'
  1050.  
  1051. mingw32
  1052. -------
  1053.  
  1054.    The Minimalists' GNU Win32 environment, mingw32, allows a large
  1055. number of Unix programs - including GPC and GCC - to run under MS
  1056. Windows 95/98/NT using native MS libraries. mingw32 ressources can be
  1057. found at:
  1058.  
  1059.      `http://agnes.dida.physik.uni-essen.de/~janjaap/mingw32/'
  1060.      `http://www.xraylith.wisc.edu/~khan/software/gnu-win32/'
  1061.  
  1062. 
  1063. File: gpc.info,  Node: Binary Distributions,  Next: Compiling GPC,  Prev: Download,  Up: Installation
  1064.  
  1065. Installation instructions for a GPC binary distribution
  1066. =======================================================
  1067.  
  1068.    To install a binary distribution, `cd' to the root directory and
  1069. unpack the archive while preserving the stored directory structure.
  1070. Under a Unix compatible system with GNU `tar' installed, the following
  1071. (performed as `root') will do the job:
  1072.  
  1073.      # cd /
  1074.      # tar xzf ARCHIVE.tar.gz
  1075.  
  1076.    If you are using a `tar' utility other than GNU `tar', it might be
  1077. necessary to do the above in an explicit pipe:
  1078.  
  1079.      # cd /
  1080.      # gzip -c -d ARCHIVE.tar.gz | tar xf -
  1081.  
  1082.    If you want to install a GPC binary distribution in another directory
  1083. than it was prepared for (for example, if you do not have root access
  1084. to the computer and want to install GPC somewhere under your home
  1085. directory), you can do the following:
  1086.  
  1087.    - Unpack the archive file in a directory of your choice (see above).
  1088.  
  1089.    - `cd' to the "prefix" directory of the distribution (for instance
  1090.      `usr/local').
  1091.  
  1092.    - Run the script `install-gpc-binary', available from
  1093.      `ftp://agnes.dida.physik.uni-essen.de/gnu-pascal/current/binary/'.
  1094.  
  1095.    - Follow the instructions in the script.
  1096.  
  1097.    To install a ZIP archive under DOS with `PKunzip', `cd' the the
  1098. appropriate directory (usually `\' for EMX, `\DJGPP' for DJGPP), then
  1099. call `PKunzip' with the `-d' option:
  1100.  
  1101.      C:\> cd djgpp
  1102.      C:\DJGPP> pkunzip -d ARCHIVE.zip
  1103.  
  1104.    where `ARCHIVE.zip' is the name of the distribution file.
  1105.  
  1106.    For DJGPP you must edit your `djgpp.env' in the `DJGPP' directory to
  1107. complete the installation: Please copy the entries from `[gcc]' to
  1108. create a new `[gpc]' section. The result may look as follows:
  1109.  
  1110.      [gcc]
  1111.      COMPILER_PATH=%/>;COMPILER_PATH%%DJDIR%/bin
  1112.      LIBRARY_PATH=%/>;LIBRARY_PATH%%DJDIR%/lib
  1113.      
  1114.      [gpc]
  1115.      COMPILER_PATH=%/>;COMPILER_PATH%%DJDIR%/bin
  1116.      LIBRARY_PATH=%/>;LIBRARY_PATH%%DJDIR%/lib
  1117.  
  1118.    If you are using the DJGPP version of GPC but do not have a `DJGPP'
  1119. directory, please download and install DJGPP (*note Download::).
  1120.  
  1121.    Binary distributions include `libgcc.a' and `specs', files that are
  1122. normally part of GCC. If you have GCC installed, they will be replaced
  1123. unless you manually install the archive.
  1124.  
  1125. 
  1126. File: gpc.info,  Node: Compiling GPC,  Next: Compilation Notes,  Prev: Binary Distributions,  Up: Installation
  1127.  
  1128. Compiling GPC
  1129. =============
  1130.  
  1131.    The preferred way to distribute GNU software is distribution of the
  1132. source code. However, it can be a non-trivial exercise to build GNU
  1133. Pascal on some non-Unix systems, so we also provide ready-to-run
  1134. binaries for a number of platforms. (See *Note Binary Distributions::
  1135. for how to install a binary distribution.)
  1136.  
  1137.    GPC is based on the GNU Compiler Collection, GNU CC or GCC. You will
  1138. need the GCC sources to build it. It must be the same version as the
  1139. one GPC is implemented with - `version 2.95.x' as of this writing.
  1140. Although you need GCC to build the GNU Pascal compiler, you don't need
  1141. GCC to compile Pascal programs once GNU Pascal is installed. (However,
  1142. using certain libraries will require compiling C wrappers, so it is a
  1143. good idea to install the C compiler as well.)
  1144.  
  1145.    Because GNU Pascal shares its back-end with GCC, it should run on any
  1146. system supported by GCC. A full list of platforms supported by GCC can
  1147. be found in *Note the GCC installation instructions: (gcc)Installation.
  1148.  
  1149.    The GCC source can be obtained from any mirror of the GNU FTP site,
  1150. `ftp://ftp.gnu.org/gnu/gcc/'. The "core" distribution is sufficient for
  1151. GPC.
  1152.  
  1153.    Here is the generic procedure for installing GNU Pascal on a Unix
  1154. system. See *Note Compilation Notes:: for extra information needed to
  1155. install GPC on DOS-like platforms.
  1156.  
  1157.   1. Checking the prerequisites
  1158.  
  1159.      Make sure that GNU make is installed. (In the following, we will
  1160.      simply speak of `make' when invoking GNU make; you might need to
  1161.      call `gmake' instead.)
  1162.  
  1163.      For extracting the example programs from the documentation to the
  1164.      `doc/docdemos' directory a non-crippled `sed' is needed.  GNU sed
  1165.      is known to work.
  1166.  
  1167.      If you have checked out the GPC source from CVS, you will have to
  1168.      rebuild most derived files, so you will need additional tools:
  1169.      `bison', `flex', `makeinfo', `gperf', and `autoconf'. Make sure
  1170.      that these are installed.
  1171.  
  1172.      If you want to build the GPC WWW pages you will also need:
  1173.      `texi2html' version 1.61 (older versions are missing some needed
  1174.      features; newer versions suffer from a bug), `texi2dvi', TeX,
  1175.      `gzip', `dvips', `dviselect', and `dviconcat'.
  1176.  
  1177.      If you run into trouble during the installation process, please
  1178.      check whether you are using outdated versions of the required
  1179.      utilities and upgrade if necessary.
  1180.  
  1181.      The GNU versions of the packages above are available from the GNU
  1182.      FTP server (ftp://ftp.gnu.org) or any of its mirrors.  Package
  1183.      PACKAGE is usually located in the directory `gnu/PACKAGE'.
  1184.  
  1185.   2. Unpacking the source
  1186.  
  1187.      From a directory of your choice (e.g. `/home/fred'), unpack the
  1188.      GCC and GNU Pascal source distributions. This will create separate
  1189.      subdirectories for GCC and GPC. Let us assume `gcc-2.95.1' and
  1190.      `gpc-20000535' in this example.
  1191.           % cd /home/fred
  1192.           % gzip -c -d gcc-core-2.95.1.tar.gz | tar xf -
  1193.           % gzip -c -d gpc-20000535.tar.gz | tar xf -
  1194.  
  1195.      `cd' to the GPC directory and move the contents (a subdirectory
  1196.      `p') to the subdirectory `gcc' of the GCC directory:
  1197.  
  1198.           % cd /home/fred/gpc-20000535
  1199.           % mv p /home/fred/gcc-2.95.1/gcc/
  1200.  
  1201.      It is recommended, though not required, to use a separate
  1202.      directory for building the compiler, rather than compiling in the
  1203.      source directory. In this example, let us create
  1204.      `/home/fred/gpc-build' for this purpose:
  1205.  
  1206.           % mkdir /home/fred/gpc-build
  1207.  
  1208.      If you use a separate directory, you do not need to write into the
  1209.      GCC source directory once you have patched the GCC source (see
  1210.      below), and can build GPC for more than one platform from the same
  1211.      source tree.
  1212.  
  1213.      In case you are re-using a directory where you have already built
  1214.      GCC and/or GPC for a different target machine, do `make distclean'
  1215.      to delete all files that might be invalid. One of the files this
  1216.      deletes is `Makefile'; if `make distclean' complains that
  1217.      `Makefile' does not exist, it probably means that the directory is
  1218.      already suitably clean.
  1219.  
  1220.   3. Configuring and building GCC
  1221.  
  1222.      GNU Pascal is automatically configured with GCC. Configuration of
  1223.      GCC is treated in depth in *Note the GCC installation
  1224.      instructions: (gcc)Installation. The normal procedure is as
  1225.      follows:
  1226.  
  1227.      `cd' to the GPC build directory. From there, run the `configure'
  1228.      script in the GCC source directory:
  1229.  
  1230.           % cd /home/fred/gpc-build
  1231.           % /home/fred/gcc-2.95.1/configure --enable-languages=pascal
  1232.  
  1233.      This creates all the necessary config files, links and Makefile in
  1234.      the GCC object directory.
  1235.  
  1236.      Note 1: The configuration will prompt you for patching the GCC
  1237.      source for GPC support, so you need write access to that
  1238.      directory. All changes to GCC are surrounded by `#ifdef GPC ...
  1239.      #endif', so they should not interfere when you build a C compiler
  1240.      from this source tree.
  1241.  
  1242.      Note 2: The `--enable-languages=pascal' option means that we only
  1243.      want to build the Pascal compiler and not, for instance, the C++
  1244.      compiler.
  1245.  
  1246.      Note 3: The standard base directory for installing GCC and GPC is
  1247.      `/usr/local'. If you want to install files to an alternate
  1248.      directory DIR, specify `--prefix=DIR' when you run `configure'.
  1249.  
  1250.   4. Putting other GNU tools in place
  1251.  
  1252.      Some environments require other GNU tools (such as the GNU
  1253.      assembler or linker) instead of the standard system tools for GCC
  1254.      to work. (See the GCC installation instructions for details.) If
  1255.      this is the case for your system, install the required tools in
  1256.      the GPC build directory under the names `as', `ld', or whatever is
  1257.      appropriate. This will enable the compiler to find the proper
  1258.      tools for compilation of the program `enquire' (a part of GCC) and
  1259.      to install the GNU tools to a place where they are found by GCC
  1260.      but do not interfere with the standard system tools.
  1261.  
  1262.      Alternatively, you can do subsequent compilation using a value of
  1263.      the `PATH' environment variable such that the necessary GNU tools
  1264.      come before the standard system tools.
  1265.  
  1266.   5. Compiling GPC
  1267.  
  1268.      Once you are satisfied with the configuration as determined by
  1269.      `configure', you can build the compiler:
  1270.  
  1271.           % make
  1272.  
  1273.      Notice that this procedure will build the C compiler (and maybe
  1274.      some other compilers) too, because that is used to compile the GPC
  1275.      runtime library.
  1276.  
  1277.      Optionally, you may supply CFLAGS, LDFLAGS or RTSFLAGS. CFLAGS is
  1278.      used for compiler and RTS, RTSFLAGS are for RTS only, i.e.: `make
  1279.      CFLAGS="-O2" RTSFLAGS=-Wall'
  1280.  
  1281.   6. Completing the installation
  1282.  
  1283.      When everything has been compiled, you can check the installation
  1284.      process with:
  1285.  
  1286.           % make -n install
  1287.  
  1288.      To complete the installation, run the command `make install'. You
  1289.      need write access to the target directories (`/usr/local/bin',
  1290.      `/usr/local/lib', `/usr/local/info', `/usr/local/doc', and
  1291.      `/usr/local/man' in this example), so this is usually done as
  1292.      `root':
  1293.  
  1294.           % su -c "make install"
  1295.  
  1296.      If you want to install _only_ the Pascal compiler (for example if
  1297.      you already have the correct version of GCC installed), `cd' to the
  1298.      `gcc' subdirectory of the build directory (e.g.
  1299.      `/home/fred/gpc-build/gcc') and run `make pascal.install'. This
  1300.      installation process does *not* overwrite existing copies of
  1301.      `libgcc.a' or `specs', should they exist.
  1302.  
  1303.      Also from the `gcc' subdirectory you can do some more "exotic"
  1304.      builds. For instance, you can build the GPC WWW pages by typing
  1305.      `make pascal.html' or a binary distribution by typing `make
  1306.      pascal.bindist'. See the `Makefile' in that directory for more
  1307.      examples.
  1308.  
  1309. 
  1310. File: gpc.info,  Node: Compilation Notes,  Next: Cross-Compilers,  Prev: Compiling GPC,  Up: Installation
  1311.  
  1312. Compilation notes for specific platforms
  1313. ========================================
  1314.  
  1315. * Menu:
  1316.  
  1317. * MS-DOS with DJGPP::        The DJGPP port of GNU compilers to MS-DOS.
  1318. * MS-DOS or OS/2 with EMX::  The EMX port of GNU compilers to MS-DOS and OS/2.
  1319. * MS Windows 95/98/NT::      Installation on a Windows 95/98/NT system.
  1320.  
  1321. 
  1322. File: gpc.info,  Node: MS-DOS with DJGPP,  Next: MS-DOS or OS/2 with EMX,  Up: Compilation Notes
  1323.  
  1324. MS-DOS with DJGPP
  1325. -----------------
  1326.  
  1327.    The only compiler that is capable of compiling the GNU Compiler
  1328. Collection (GNU CC or GCC) under MS-DOS is GCC itself. In order to
  1329. compile GPC or GCC for MS-DOS with DJGPP you will therefore need either
  1330. a working copy of DJGPP installed, or you will have to cross-build from
  1331. a non-MS-DOS system.
  1332.  
  1333.    Building GPC under MS-DOS with DJGPP follows the same scheme as
  1334. building GPC under a Unix-like system: Place the `p' subdirectory in the
  1335. `gcc' directory and follow the instructions for compiling GCC. This
  1336. requires `bash' and many other tools installed, and you must be very
  1337. careful at many places to circumvent the limitations of the DOS
  1338. platform.
  1339.  
  1340.    Our preferred way to build GPC for DJGPP is to cross-build it from a
  1341. Unix-like platform - which is much easier. For instructions, see *Note
  1342. Cross-Compilers:: and *Note Crossbuilding::.
  1343.  
  1344. 
  1345. File: gpc.info,  Node: MS-DOS or OS/2 with EMX,  Next: MS Windows 95/98/NT,  Prev: MS-DOS with DJGPP,  Up: Compilation Notes
  1346.  
  1347. MS-DOS or OS/2 with EMX
  1348. -----------------------
  1349.  
  1350.    EMX is a free 32-bit DOS extender which adds some properties of Unix
  1351. to MS-compatible DOS and IBM's OS/2 operating systems.
  1352.  
  1353.    As of this writing, we are not aware of current versions of GCC for
  1354. EMX, and EMX support in GPC has not been maintained. Please contact us
  1355. if you know about recent development in EMX and are interested in
  1356. continuing EMX support in GPC.
  1357.  
  1358.